<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

    <title></title>
    [#include "/admin/include/admin_static.htm"]
    <script type="text/javascript" src="${path}/resources/admin/js/jquery-1.7.1.min.js"></script>
    <script type="text/javascript" src="${path}/resources/admin/js/jquery.form.js"></script>
    <script type="text/javascript">
        $(function () {
            layui.use(['form', 'layer','upload','layedit'], function () {
                var form = layui.form(), $ = layui.jquery, layer = layui.layer,upload = layui.upload,layedit = layui.layedit;
                layui.upload({
                    url: '/system/upload/submit.aspx'
                    ,success: function(res){
                        if (res["error"] == 0) {
                            $("#logoImg").attr("src", res["url"]);
                            $("#logo").val(res["url"]);
                        } else {
                            layui.alert(res["message"]);
                        }
                    }
                });

                form.on('submit(saveForm)', function (data) {
                    var index = layer.load();
                    ajax({
                        url: "${path}/admin/link/edit.aspx",
                        data: data.field,
                        success: function (result) {
                            layer.msg(result.content, {time:2000},function () {
                                location.href="${path}/admin/link/list.aspx";
                            });
                            layer.close(index);
                        },
                        complete: function () {
                            layer.close(index);
                        }

                    });
                    return false;
                });
            });
        });
    </script>


</head>
<body>
<div class="main_admin_content">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>编辑连接</legend>
    </fieldset>
    <form class="layui-form">


            <div class="layui-form-item">
                <label class="layui-form-label">选择文件：</label>
                <div class="layui-input-block" style="margin-left: 150px">
                    <input type="file" name="file"  class="layui-upload-file"/>
                    <img id="logoImg" width="90px" height="90px" src="${link.logo}"/>
                    <input type="hidden" id="logo" name="logo" value="${link.logo}" />
                </div>
            </div>

            <input type="hidden" value="${link.id}" name="id"/>
            <div class="layui-form-item">
                <label class="layui-form-label">标题：</label>
                <div class="layui-input-block" style="margin-left: 150px">
                    <input name="name" type="text" value="${link.name}" class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">地址：</label>
                <div class="layui-input-block" style="margin-left: 150px">
                    <input name="link" type="text" value="${link.link}" class="layui-input"/>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">排序order：</label>
                <div class="layui-input-block" style="margin-left: 150px">
                    <input name="orderid" type="text"
                           value="${link.orderid}" onkeyup="value=value.replace(/[^\d]/g,'')"  class="layui-input"/>
                </div>
            </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button lay-submit lay-filter="saveForm" class="layui-btn" style="width: 280px;margin-top:3px;">保存</button>
            </div>
        </div>
    </form>
</div>
</body>
</html>